package com.tqjc.common.faulthandle.enums;

import com.tqjc.area.service.RefreshConfigCacheService;
import com.tqjc.execute.consts.WorkConst;
import com.tqjc.execute.utils.StaticMethod;
import com.tqjc.system.common.constant.ConfigConstant;
import com.tqjc.system.common.constant.GlobalConstant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @Author: 86195
 * @CreateTime: 2024-06-14  10:38
 * @Description: TODO
 * @Version: 1.0
 */
@NoArgsConstructor
@AllArgsConstructor
@Getter
public enum ConfigCacheEnum implements RefreshConfigCacheService {
    MULT_STEEL_WAIT_CONFIG(ConfigConstant.CONFIG_TYPE_TIME,ConfigConstant.CONFIG_ID_MULT_STEEL_WAIT_SECOND,"多块板模式最长等待时间配置"){
        @Override
        public void refreshCache(Object value,Boolean flag) {
            if(flag){
                GlobalConstant.MULT_STEEL_WAIT_SECOND = Integer.parseInt(value.toString());
            } else {
                //开关关闭
                GlobalConstant.MULT_STEEL_WAIT_SECOND = 1 * 24 * 60 * 60;
            }
        }
    },

    OCT_FLAG_CONFIG(ConfigConstant.CONFIG_TYPE_FLAG, ConfigConstant.CONFIG_ID_OCT_FLAG,"特殊钢板号十月份标识") {
        @Override
        public void refreshCache(Object value, Boolean flag) {
            if(flag){
                StaticMethod.SPECIAL_STEEL_NO_OCT = value.toString();
            } else {
                //开关关闭
                StaticMethod.SPECIAL_STEEL_NO_OCT = null;
            }
        }
    },
    NOV_FLAG_CONFIG(ConfigConstant.CONFIG_TYPE_FLAG, ConfigConstant.CONFIG_ID_NOV_FLAG,"特殊钢板号十一月份标识") {
        @Override
        public void refreshCache(Object value, Boolean flag) {
            if(flag){
                StaticMethod.SPECIAL_STEEL_NO_NOV = value.toString();
            } else {
                //开关关闭
                StaticMethod.SPECIAL_STEEL_NO_NOV = null;
            }
        }
    },

    NO2_DEBUG_FLAG_CONFIG(ConfigConstant.CONFIG_TYPE_FLAG, ConfigConstant.CONFIG_ID_NO2_DEBUG_FLAG,"2号横移车调试开关") {
        @Override
        public void refreshCache(Object value, Boolean flag) {
            if(flag){
                WorkConst.CRANE_DEBUG_SWITCH_FLAG = Boolean.valueOf(value.toString());
            } else {
                //开关关闭
                WorkConst.CRANE_DEBUG_SWITCH_FLAG = false;
            }
        }
    },

    DEC_FLAG_CONFIG(ConfigConstant.CONFIG_TYPE_FLAG, ConfigConstant.CONFIG_ID_DEC_FLAG,"特殊钢板号十二月份标识") {
        @Override
        public void refreshCache(Object value, Boolean flag) {
            if(flag){
                StaticMethod.SPECIAL_STEEL_NO_DEC = value.toString();
            } else {
                //开关关闭
                StaticMethod.SPECIAL_STEEL_NO_DEC = null;
            }
        }
    };


    private String configType;

    private String configId;

    private String desc;


    public static ConfigCacheEnum getConfigCacheEnum(String configId, String configType) {

        for (ConfigCacheEnum value : ConfigCacheEnum.values()) {
            if(value.getConfigId().equals(configId) && value.getConfigType().equals(configType)){
                return value;
            }
        }
        return null;
    }
}
